/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.solitaire.web.controller.manager;

import com.medusa.gruul.common.core.util.PageUtils;
import com.medusa.gruul.common.core.util.Result;
import com.medusa.gruul.solitaire.api.model.dto.manager.SolitaireActivityDto;
import com.medusa.gruul.solitaire.api.model.param.manager.SolitaireActivityParam;
import com.medusa.gruul.solitaire.api.model.vo.manager.SolitaireActivitySimpleVo;
import com.medusa.gruul.solitaire.api.model.vo.manager.SolitaireActivityVo;
import com.medusa.gruul.solitaire.service.manager.ISolitaireActivityService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 接龙活动信息 前端控制器
 * </p>
 *
 * @author lcysike
 * @since 2020-06-05
 */
@RestController
@RequestMapping("/manager/activity")
public class SolitaireActivityController {

    @Autowired
    private ISolitaireActivityService solitaireActivityService;

    /**
     * 接龙活动信息列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "接龙活动信息列表")
    public Result<PageUtils<SolitaireActivityVo>> getActivityList(SolitaireActivityParam solitaireActivityParam) {
        PageUtils<SolitaireActivityVo> pageUtils = new PageUtils(solitaireActivityService.getActivityList(solitaireActivityParam));
        return Result.ok(pageUtils);
    }

    /**
     * 获取接龙活动信息明细
     */
    @GetMapping("/get/{id}")
    @ApiOperation(value = "获取活动信息明细")
    public Result<SolitaireActivitySimpleVo> getActivityById(@ApiParam(value = "接龙活动id", required = true) @PathVariable("id") Long id) {
        SolitaireActivitySimpleVo solitaireActivitySimpleVo = solitaireActivityService.getActivityById(id);
        return Result.ok(solitaireActivitySimpleVo);
    }

    /**
     * 接龙活动新增
     */
    @PostMapping("/add")
    @ApiOperation(value = "接龙活动新增")
    public Result addActivity(@RequestBody @Validated SolitaireActivityDto solitaireActivityDto) {
        solitaireActivityService.addActivity(solitaireActivityDto);
        return Result.ok();
    }

    /**
     * 接龙活动修改
     */
    @PutMapping("/update")
    @ApiOperation(value = "接龙活动修改")
    public Result updateActivity(@RequestBody @Validated SolitaireActivityDto solitaireActivityDto) {
        solitaireActivityService.updateActivity(solitaireActivityDto);
        return Result.ok();
    }

    /**
     * 接龙活动关闭
     */
    @PutMapping("/changeStatus/{id}")
    @ApiOperation(value = "接龙活动关闭")
    public Result changeActivityStatus(@ApiParam(value = "接龙活动id", required = true) @PathVariable(name = "id") Long id) {
        solitaireActivityService.changeActivityStatus(id);
        return Result.ok();
    }

    /**
     * 接龙活动删除
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "接龙活动删除")
    public Result deleteActivity(@ApiParam(value = "接龙活动id", required = true) @PathVariable(name = "id") Long id) {
        solitaireActivityService.deleteActivity(id);
        return Result.ok();
    }
}
